package com.ruimei;

import com.alibaba.druid.pool.DruidDataSource;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

@Configuration
@ConfigurationProperties(prefix="primary.datasource.druid")
@MapperScan(basePackages={"com.ruimei.mapper"}, sqlSessionFactoryRef="primarySqlSessionFactory")
public class PrimaryDataBaseConfig
{
  static final String PACKAGE = "com.ruimei.mapper";
  private static final String MAPPER_LOCATION = "classpath:mybatis/mapper/*.xml";
  private String filters;
  private String url;
  private String username;
  private String password;
  private String driverClassName;
  private int initialSize;
  private int minIdle;
  private int maxActive;
  private long maxWait;
  private long timeBetweenEvictionRunsMillis;
  private long minEvictableIdleTimeMillis;
  private String validationQuery;
  private boolean testWhileIdle;
  private boolean testOnBorrow;
  private boolean testOnReturn;
  private boolean poolPreparedStatements;
  private int maxPoolPreparedStatementPerConnectionSize;
  
  public void setFilters(String filters)
  {
    this.filters = filters;
  }
  
  public void setUrl(String url)
  {
    this.url = url;
  }
  
  public void setUsername(String username)
  {
    this.username = username;
  }
  
  public void setPassword(String password)
  {
    this.password = password;
  }
  
  public void setDriverClassName(String driverClassName)
  {
    this.driverClassName = driverClassName;
  }
  
  public void setInitialSize(int initialSize)
  {
    this.initialSize = initialSize;
  }
  
  public void setMinIdle(int minIdle)
  {
    this.minIdle = minIdle;
  }
  
  public void setMaxActive(int maxActive)
  {
    this.maxActive = maxActive;
  }
  
  public void setMaxWait(long maxWait)
  {
    this.maxWait = maxWait;
  }
  
  public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
  {
    this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
  }
  
  public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
  {
    this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
  }
  
  public void setValidationQuery(String validationQuery)
  {
    this.validationQuery = validationQuery;
  }
  
  public void setTestWhileIdle(boolean testWhileIdle)
  {
    this.testWhileIdle = testWhileIdle;
  }
  
  public void setTestOnBorrow(boolean testOnBorrow)
  {
    this.testOnBorrow = testOnBorrow;
  }
  
  public void setTestOnReturn(boolean testOnReturn)
  {
    this.testOnReturn = testOnReturn;
  }
  
  public void setPoolPreparedStatements(boolean poolPreparedStatements)
  {
    this.poolPreparedStatements = poolPreparedStatements;
  }
  
  public void setMaxPoolPreparedStatementPerConnectionSize(int maxPoolPreparedStatementPerConnectionSize)
  {
    this.maxPoolPreparedStatementPerConnectionSize = maxPoolPreparedStatementPerConnectionSize;
  }
  
  public boolean equals(Object o)
  {
    if (o == this) {
      return true;
    }
    if (!(o instanceof PrimaryDataBaseConfig)) {
      return false;
    }
    PrimaryDataBaseConfig other = (PrimaryDataBaseConfig)o;
    if (!other.canEqual(this)) {
      return false;
    }
    Object this$filters = getFilters();Object other$filters = other.getFilters();
    if (this$filters == null ? other$filters != null : !this$filters.equals(other$filters)) {
      return false;
    }
    Object this$url = getUrl();Object other$url = other.getUrl();
    if (this$url == null ? other$url != null : !this$url.equals(other$url)) {
      return false;
    }
    Object this$username = getUsername();Object other$username = other.getUsername();
    if (this$username == null ? other$username != null : !this$username.equals(other$username)) {
      return false;
    }
    Object this$password = getPassword();Object other$password = other.getPassword();
    if (this$password == null ? other$password != null : !this$password.equals(other$password)) {
      return false;
    }
    Object this$driverClassName = getDriverClassName();Object other$driverClassName = other.getDriverClassName();
    if (this$driverClassName == null ? other$driverClassName != null : !this$driverClassName.equals(other$driverClassName)) {
      return false;
    }
    if (getInitialSize() != other.getInitialSize()) {
      return false;
    }
    if (getMinIdle() != other.getMinIdle()) {
      return false;
    }
    if (getMaxActive() != other.getMaxActive()) {
      return false;
    }
    if (getMaxWait() != other.getMaxWait()) {
      return false;
    }
    if (getTimeBetweenEvictionRunsMillis() != other.getTimeBetweenEvictionRunsMillis()) {
      return false;
    }
    if (getMinEvictableIdleTimeMillis() != other.getMinEvictableIdleTimeMillis()) {
      return false;
    }
    Object this$validationQuery = getValidationQuery();Object other$validationQuery = other.getValidationQuery();
    if (this$validationQuery == null ? other$validationQuery != null : !this$validationQuery.equals(other$validationQuery)) {
      return false;
    }
    if (isTestWhileIdle() != other.isTestWhileIdle()) {
      return false;
    }
    if (isTestOnBorrow() != other.isTestOnBorrow()) {
      return false;
    }
    if (isTestOnReturn() != other.isTestOnReturn()) {
      return false;
    }
    if (isPoolPreparedStatements() != other.isPoolPreparedStatements()) {
      return false;
    }
    return getMaxPoolPreparedStatementPerConnectionSize() == other.getMaxPoolPreparedStatementPerConnectionSize();
  }
  
  protected boolean canEqual(Object other)
  {
    return other instanceof PrimaryDataBaseConfig;
  }
  
  public int hashCode()
  {
    int PRIME = 59;int result = 1;Object $filters = getFilters();result = result * 59 + ($filters == null ? 43 : $filters.hashCode());Object $url = getUrl();result = result * 59 + ($url == null ? 43 : $url.hashCode());Object $username = getUsername();result = result * 59 + ($username == null ? 43 : $username.hashCode());Object $password = getPassword();result = result * 59 + ($password == null ? 43 : $password.hashCode());Object $driverClassName = getDriverClassName();result = result * 59 + ($driverClassName == null ? 43 : $driverClassName.hashCode());result = result * 59 + getInitialSize();result = result * 59 + getMinIdle();result = result * 59 + getMaxActive();long $maxWait = getMaxWait();result = result * 59 + (int)($maxWait >>> 32 ^ $maxWait);long $timeBetweenEvictionRunsMillis = getTimeBetweenEvictionRunsMillis();result = result * 59 + (int)($timeBetweenEvictionRunsMillis >>> 32 ^ $timeBetweenEvictionRunsMillis);long $minEvictableIdleTimeMillis = getMinEvictableIdleTimeMillis();result = result * 59 + (int)($minEvictableIdleTimeMillis >>> 32 ^ $minEvictableIdleTimeMillis);Object $validationQuery = getValidationQuery();result = result * 59 + ($validationQuery == null ? 43 : $validationQuery.hashCode());result = result * 59 + (isTestWhileIdle() ? 79 : 97);result = result * 59 + (isTestOnBorrow() ? 79 : 97);result = result * 59 + (isTestOnReturn() ? 79 : 97);result = result * 59 + (isPoolPreparedStatements() ? 79 : 97);result = result * 59 + getMaxPoolPreparedStatementPerConnectionSize();return result;
  }
  
  public String toString()
  {
    return "PrimaryDataBaseConfig(filters=" + getFilters() + ", url=" + getUrl() + ", username=" + getUsername() + ", password=" + getPassword() + ", driverClassName=" + getDriverClassName() + ", initialSize=" + getInitialSize() + ", minIdle=" + getMinIdle() + ", maxActive=" + getMaxActive() + ", maxWait=" + getMaxWait() + ", timeBetweenEvictionRunsMillis=" + getTimeBetweenEvictionRunsMillis() + ", minEvictableIdleTimeMillis=" + getMinEvictableIdleTimeMillis() + ", validationQuery=" + getValidationQuery() + ", testWhileIdle=" + isTestWhileIdle() + ", testOnBorrow=" + isTestOnBorrow() + ", testOnReturn=" + isTestOnReturn() + ", poolPreparedStatements=" + isPoolPreparedStatements() + ", maxPoolPreparedStatementPerConnectionSize=" + getMaxPoolPreparedStatementPerConnectionSize() + ")";
  }
  
  public String getFilters()
  {
    return this.filters;
  }
  
  public String getUrl()
  {
    return this.url;
  }
  
  public String getUsername()
  {
    return this.username;
  }
  
  public String getPassword()
  {
    return this.password;
  }
  
  public String getDriverClassName()
  {
    return this.driverClassName;
  }
  
  public int getInitialSize()
  {
    return this.initialSize;
  }
  
  public int getMinIdle()
  {
    return this.minIdle;
  }
  
  public int getMaxActive()
  {
    return this.maxActive;
  }
  
  public long getMaxWait()
  {
    return this.maxWait;
  }
  
  public long getTimeBetweenEvictionRunsMillis()
  {
    return this.timeBetweenEvictionRunsMillis;
  }
  
  public long getMinEvictableIdleTimeMillis()
  {
    return this.minEvictableIdleTimeMillis;
  }
  
  public String getValidationQuery()
  {
    return this.validationQuery;
  }
  
  public boolean isTestWhileIdle()
  {
    return this.testWhileIdle;
  }
  
  public boolean isTestOnBorrow()
  {
    return this.testOnBorrow;
  }
  
  public boolean isTestOnReturn()
  {
    return this.testOnReturn;
  }
  
  public boolean isPoolPreparedStatements()
  {
    return this.poolPreparedStatements;
  }
  
  public int getMaxPoolPreparedStatementPerConnectionSize()
  {
    return this.maxPoolPreparedStatementPerConnectionSize;
  }
  
  @Primary
  @Bean(name={"primaryDataSource"})
  public DataSource primaryDataSource()
    throws SQLException
  {
    DruidDataSource druid = new DruidDataSource();
    
    druid.setFilters(this.filters);
    
    druid.setDriverClassName(this.driverClassName);
    druid.setUsername(this.username);
    druid.setPassword(this.password);
    druid.setUrl(this.url);
    
    druid.setInitialSize(this.initialSize);
    
    druid.setMaxActive(this.maxActive);
    
    druid.setMinIdle(this.minIdle);
    
    druid.setMaxWait(this.maxWait);
    
    druid.setTimeBetweenEvictionRunsMillis(this.timeBetweenEvictionRunsMillis);
    
    druid.setMinEvictableIdleTimeMillis(this.minEvictableIdleTimeMillis);
    
    druid.setValidationQuery(this.validationQuery);
    
    druid.setTestWhileIdle(this.testWhileIdle);
    
    druid.setTestOnBorrow(this.testOnBorrow);
    druid.setTestOnReturn(this.testOnReturn);
    
    druid.setPoolPreparedStatements(this.poolPreparedStatements);
    
    druid.setMaxPoolPreparedStatementPerConnectionSize(this.maxPoolPreparedStatementPerConnectionSize);
    
    return druid;
  }
  
  @Primary
  @Bean(name={"primaryTransactionManager"})
  public DataSourceTransactionManager primaryTransactionManager()
    throws SQLException
  {
    return new DataSourceTransactionManager(primaryDataSource());
  }
  
  @Primary
  @Bean(name={"primarySqlSessionFactory"})
  public SqlSessionFactory primarySqlSessionFactory(@Qualifier("primaryDataSource") DataSource primaryDataSource)
    throws Exception
  {
    SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
    sessionFactory.setDataSource(primaryDataSource);
    sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver()
      .getResources("classpath:mybatis/mapper/*.xml"));
    
    return sessionFactory.getObject();
  }
}


/* Location:              E:\360MoveData\Users\admin\Desktop\teacher_wap-0.0.1-SNAPSHOT.jar!\BOOT-INF\classes\com\ruimei\PrimaryDataBaseConfig.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       0.7.1
 */